<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <title>{$streamList[0]['title']}-见微-全媒体记者发稿助手</title>
    <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css">
    <link href="__PUBLIC__/live/css/base.css" rel="stylesheet">
    <link href="__PUBLIC__/live/css/show-detail.v2.0.css" rel="stylesheet">
    <link rel="stylesheet" href="__PUBLIC__/live/css/selectbox.css" type="text/css">
    <link rel="stylesheet" href="__PUBLIC__/live/css/dialogSelect.css" type="text/css">
    <link rel="stylesheet" href="http://cdn.bootcss.com/font-awesome/4.6.3/css/font-awesome.min.css">
    <script src="http://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
<!--    <script src="__PUBLIC__/ueditor/ueditor.config.js"></script>
    <script src="__PUBLIC__/ueditor/ueditor.all.js"></script>-->
    <link rel="stylesheet" href="http://g.alicdn.com/de/prismplayer/1.5.7/skins/default/index.css" />
    <script type="text/javascript" src="//g.alicdn.com/de/prismplayer/1.5.7/prism-min.js"></script>
    <script src="//cdn.bootcss.com/clipboard.js/1.5.12/clipboard.min.js"></script>
    <script src="http://cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
    <link href="__PUBLIC__/datetimepicker/css/bootstrap-datetimepicker.min.css" rel="stylesheet">
    <script src="__PUBLIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
    <script src="__PUBLIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
    <script src="__PUBLIC__/live/js/changtopy.js"></script>
    <script src="__PUBLIC__/live/js/getpyszm.js"></script>
    <script src="__PUBLIC__/live/js/jquery.multiseselect.js"></script>
    <script src="__PUBLIC__/live/js/range/js/ion.rangeSlider.js"></script>
    <script src="http://cdn.hcharts.cn/highcharts/highcharts.js"></script>
    <script src="//cdn.bootcss.com/reconnecting-websocket/1.0.0/reconnecting-websocket.min.js"></script>
    <link rel="stylesheet" href="__PUBLIC__/live/css/spinners.css">
    <link rel="stylesheet" href="__PUBLIC__/live/js/range/css/ion.rangeSlider.css">
    <link rel="stylesheet" href="__PUBLIC__/live/js/range/css/ion.rangeSlider.skinFlat.css">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/webUploader/webuploader.css">
    <script type="text/javascript" src="__PUBLIC__/webUploader/webuploader.min.js"></script>
    <link href="__PUBLIC__/live/css/bootstrap-switch.min.css" rel="stylesheet">
    <script src="__PUBLIC__/live/js/bootstrap-switch.min.js"></script>
</head>

<body>
<include file="Public:header"/>
<div class="break">
    <a href="/Live">主页</a> &gt; <a href="{:U('live_list')}">云导播</a> &gt; <span>{$streamList[0]['title']}</span>
</div>
<div class="main-content">
    <div class="wrap">
        <div class="detail">
            <div class="detail-header row">
                <?php if($auth['is_manage'] == 1) { ?>
                    <!--<div class="col-33">
                        <div class="detail-title">直播状态</div>
                        <div class="btn"  style="padding: 0">
                            <label class="switch">
                                <input class="switch-input" type="checkbox" name="liveStatus" id="liveStatus" data-groupid="{$streamList[0]['group_id']}"  <?php if($streamList[0]['group_status'] != 3) { ?>checked<?php } ?> />
                                <span class="switch-label <?php if($streamList[0]['group_status'] == 3) { ?>disabled<?php } ?>" data-on="开始" data-off="结束"></span>
                                <span class="switch-handle"></span>
                            </label>
                        </div>
                    </div>-->
                    <?php if($streamList[0]['group_status'] != 3) { ?>
                        <!--<div class="col-33">
                            <div class="detail-title">推流通道</div>
                            <div class="btn" style="padding: 0">

                                <label class="switch t">
                                    <input class="switch-input" type="checkbox" name="pushStream" id="pushStream"  data-groupid="{$streamList[0]['group_id']}"  <?php if($streamList[0]['group_status'] != 0) { ?>checked<?php } ?> />
                                    <span class="switch-label" data-on="开" data-off="关"></span>
                                    <span class="switch-handle"></span>
                                </label>

                            </div>
                        </div>-->
                    <?php } ?>
                    <div class="col-xs-8 text-center">
                        <div class="row statusbtnlist" data-groupid="{$streamList[0]['group_id']}">
                            <div class="col-xs-2 col-xs-offset-2"><button id="setPreview" data-status="0" type="button" class="btn btn-block <eq name='streamList[0]["group_status"]' value='0'>btn-danger" disabled<else/>btn-default"</eq>>设为预告</button></div>
                            <div class="col-xs-2"><button type="button" id="setLive" data-status="1"  class="btn btn-block <in name='streamList[0]["group_status"]' value='1,2'>btn-danger" disabled<else/>btn-default"</in>>设为直播</button></div>

                            <div class="col-xs-2"><button type="button" id="setrReview" data-status="3"  class="btn btn-block <eq name='streamList[0]["group_status"]' value='3'>btn-danger" disabled<else/>btn-default"</eq>>设为回看</button></div>
                        </div>
                    </div>

                <?php } ?>
                <div class="col-xs-2 col-xs-offset-2">
                    <div class="imgClass">视频地址  <i class="fa fa-link" aria-hidden="true"></i></div>
                </div>

            </div>

            <?php if($auth['is_manage'] == 1) { ?>
                <div class="manger-switch">
                    <botton class="btn btn-sm btn-default" id="showDetail" data-toggle="modal" data-target="#liveInfo">设置详情</botton>
                    <!--<button type="button" class="btn btn-sm btn-info" id="sortBtn">更新排序</button>-->
                    |
                    <?php if(isset($is_super) && $is_super) { ?>
                        <button type="button" class="btn btn-sm btn-default" id="managePos" >机位管理</button>
                        <?php if($streamList[0]['is_push'] == 0) { ?>
                            <button type="button" class="btn btn-sm btn-default" id="pushBtn" data-status="1">签发列表</button>
                        <?php } else { ?>
                            <button type="button" class="btn btn-sm btn-default" id="pushBtn" data-status="0">撤回列表</button>
                        <?php } ?>
                    <!--
                        <?php if($streamList[0]['is_top'] == 0) { ?>
                            <button type="button" class="btn btn-sm btn-default" id="topBtn" data-status="1">点击置顶</button>
                        <?php } else { ?>
                            <button type="button" class="btn btn-sm btn-default" id="topBtn" data-status="0">取消置顶</button>
                        <?php } ?>
                    -->
                    <?php } ?>

                    <?php if($_SESSION['is_admin']) { ?>
                    |
                        <botton type="button" class="btn btn-sm btn-default set-auth" id="setAuthBtn">设置监管人员</botton>
                    <?php } ?>
                    
                    <botton type="button" class="btn btn-sm btn-default set-auth" id="comment">评论管理</botton>
                    |

                    评论审核模式：
                    <?php if($streamList[0]['is_verify'] == 0) { ?>
                    <input type="checkbox" name="is_verify" data-on-color="danger" data-off-text="先发后审" data-on-text="先审后发" data-size="small">
                    <?php } else { ?>
                    <input type="checkbox" name="is_verify"  data-on-color="danger" checked data-off-text="先发后审" data-on-text="先审后发" data-size="small">
                    <?php } ?>

                </div>
            <?php } ?>

            <!--<div class="manger-switch">
                <label>{$seeTotal}</label>
                <button type="button" class="btn btn-ms btn-info" id="recordBtn" data-groupid="{$streamList[0]['group_id']}">详情</button>
            </div>-->

            <ul class="tab liveView">
                <volist name="streamList" id="vo">
                    <li class="detail-list">
                        <div class="pos_name" title="双击修改信息" data-id="{$vo.id}"><?php if($vo['pos_name']){echo $vo['pos_name'];}else{echo $i.'号机位';} ?></div>
                        <div class="detail-item">

                            <div class="detail-img">

                                <div id="J_prismPlayer_{$vo.id}" class="prism-player"></div>
                                <script>
                                <?php if(is_mobile()){ ?>
                                    var player_{$vo.id} = new prismplayer({
                                        id: "J_prismPlayer_{$vo.id}", // 容器id
                                        <?php if($vo['userchannel']==55 || $vo['is_device']==1){ ?>
                                        source: '{:authAliyun("http://jwlive.appwuhan.com/jw/".$vo['realnamepy'].".m3u8")}',// 视频地址
                                        <?php } else if($vo['userchannel']==57){ ?>
                                        source: '{:authAliyun("http://jwlive.appwuhan.com/jwdev/".$vo['group_id']."_".$vo['user_id'].".m3u8")}',
                                        <?php } else if($vo['group_id']=='20170526162826_656_5927e72a9af59'){ ?>
                                        source: 'http://pili-live-hls.qnlive.appwuhan.com/jianwei/20170526162826_656_5927e72a9af59.m3u8',
                                        <?php }else{ ?>
                                        source: '{:authAliyun("http://jwlive.appwuhan.com/jw/".$vo['group_id']."_".$vo['user_id'].".m3u8")}',// 视频地址
                                        <?php }　?>
                                        
                                        isLive:true,
                                        cover:"{$vo.image_url}",
                                        width: "352px",
                                        height: "197px",
                                        extraInfo:{
                                            "fullTitle":"{$vo.title}-{$vo.realname}",
                                        }
                                    });
                                <?php }else{ ?>
                                    // 初始化播放器
                                    var player_{$vo.id} = new prismplayer({
                                        id: "J_prismPlayer_{$vo.id}", // 容器id
                                        <?php if($vo['userchannel']==55 || $vo['is_device']==1){ ?>
                                        source: '{:authAliyun("rtmp://jwlive.appwuhan.com/jw/".$vo['realnamepy'])}',// 视频地址
                                        <?php } else if($vo['userchannel']==57){ ?>
                                        source: '{:authAliyun("rtmp://jwlive.appwuhan.com/jwdev/".$vo['group_id']."_".$vo['user_id'])}',
                                        <?php } else if($vo['group_id']=='20170526162826_656_5927e72a9af59'){ ?>
                                        source: 'rtmp://pili-live-rtmp.qnlive.appwuhan.com/jianwei/20170526162826_656_5927e72a9af59',
                                        <?php }else{ ?>
                                        source: '{:authAliyun("rtmp://jwlive.appwuhan.com/jw/".$vo['group_id']."_".$vo['user_id'])}',// 视频地址
                                        <?php }　?>
                                        autoplay: true,
                                        isLive:true,
                                        cover:"{$vo.image_url}",
                                        width: "352px",
                                        height: "197px",
                                        extraInfo:{
                                            "fullTitle":"{$vo.title}-{$vo.realname}",
                                        }
                                    });
                                <?php } ?>

                                    player_{$vo.id}.on("liveStreamStop", function() {
                                        $("#J_prismPlayer_{$vo.id}").parents('.detail-list').find('.text-info').load("{:U('showBTNs')}?id={$vo.id}");
                                    });
                                    player_{$vo.id}.on("play", function() {
                                        $("#J_prismPlayer_{$vo.id}").parents('.detail-list').find('.text-info').load("{:U('showBTNs')}?id={$vo.id}");
                                    });
                                </script>
                            </div>
                            <div class="detail-text">

                                <div class="text-info" id="liveStatusBtns"  data-id="{$vo.id}" data-stream="{$vo['group_id']}_{$vo['user_id']}">
                                </div>
                            </div>
                        </div>
                        <div class="text-data">
                            <?php if($auth['is_manage'] == 1) { ?>
                                <!--<input type="text" class="posSort form-control" style="width: 16%; text-align: center;" data-id="{$vo.id}" value="{$vo['pos_sort']}">
                            --><?php } ?>
                            <div class="live-detail" style="display: inline-block;">
                                <span class="zbRen">{$vo.realname}</span>
                            </div>

                            <p class="btns">
                                <botton type="button" class="btn btn-xs btn-info download" data-id="{$vo.id}">获取视频</botton>
                                <?php if($auth['is_manage'] == 1) { ?>
                                    <botton type="button" class="btn btn-xs btn-info thumb" data-id="{$vo.id}">缩略图</botton>
                                    <botton type="button" class="btn btn-xs btn-info bitRate" data-id="{$vo.id}">码率</botton>
                                <?php } ?>
                                <botton type="button" class="btn btn-xs btn-info rtmp" data-id="{$vo.id}">rtmp</botton>
                            </p>

                            <!-- 系统消息发送 -->
                            <div class="push-to">
                                <div class="push-area">
                                    <input type="text" name="message" class="pushmsg" />
                                    <input type="hidden" name="group" class="sendgroup" value="{$vo['group_id']}_{$vo['user_id']}" />
                                    <input type="hidden" name="group" class="sendname" value="{$vo.realname}" />
                                </div>
                                <div class="push-btn">
                                    <botton type="button" class="btn btn-sm btn-info sendmsg">发送</botton>
                                </div>           
                            </div>
                        </div>
                    </li>
                </volist>
            </ul>
            <div class="tab livePos">
                <table class="table table-striped table-hover">
                    <tr>
                        <th width="5%">排序</th>
                        <th width="20%">机位名称</th>
                        <th width="12%">直播人</th>
                        <th width="63%">操作</th>
                    </tr>
                    <volist name="streamList" id="vo">
                        <tr>
                            <td><?php if($auth['is_manage'] == 1) { ?>
                                <input type="text" class="posSort form-control" style="text-align: center;" data-id="{$vo.id}" value="{$vo['pos_sort']}">
                                <?php }else{ ?>
                                {$vo['pos_sort']}
                                <?php } ?>
                            </td>
                            <td><div class="pos_name" title="双击修改信息" data-id="{$vo.id}"><?php if($vo['pos_name']){echo $vo['pos_name'];}else{echo $i.'号机位';} ?></div>
                            </td>
                            <td>{$vo.realname}</td>
                            <td>
                                <botton type="button" class="btn btn-xs btn-info download" data-id="{$vo.id}">获取视频</botton>
                                <?php if($auth['is_manage'] == 1) { ?>
                                <botton type="button" class="btn btn-xs btn-info thumb" data-id="{$vo.id}">缩略图</botton>
                                <!-- <botton type="button" class="btn btn-xs btn-info bitRate" data-id="{$vo.id}">码率</botton>-->
                                <?php } ?>
                                <botton type="button" class="btn btn-xs btn-info rtmp" data-id="{$vo.id}">拉流地址(rtmp)</botton>
                                <botton type="button" class="btn btn-xs btn-info m3u8" data-id="{$vo.id}">拉流地址(m3u8)</botton>
                                <botton type="button" class="btn btn-xs btn-info pushrtmp" data-id="{$vo.id}">推流地址</botton>

                            </td>
                        </tr>
                    </volist>
                    <?php if($auth['is_manage'] == 1) { ?>
                    <tr>
                        <td colspan="4" style="text-align: left">
                            <button type="button" class="btn btn-sm btn-info" id="sortBtn">更新排序</button>
                        </td>
                    </tr>
                    <?php } ?>
                </table>
            </div>

            <div class="tab comment">

                <iframe id="ifComment" src="{:U('Comment/index')}?group_id={$Think.get.group_id}" width="100%" frameborder="0"></iframe>
            </div>
            <script>
                $("#ifComment").load(function(){
                    var mainheight = $(this).contents().find('body').height()+30;
                    $(this).height(mainheight);
                });
            </script>
            <ul id="addr-model">
                <li class="close-cp"><a href="javascript:;"><i class="fa fa-times" aria-hidden="true"></i></a></li>
                 <li class="add-list">
                    自适应页面：
                    <div>
                        <input type="text" id="zsv-addr" readonly value="http://plive.appwuhan.com/{:date('Ymd',$streamList[0]['create_time'])}/jw_{:md5($streamList[0]['group_id'])}.html" >
                        <span class="label" data-label="OK" data-clipboard-target="#zsv-addr"> 复制 <i class="fa fa-hand-pointer-o" aria-hidden="true"></i></span>
                    </div>
                </li>
                <li class="add-list">
                    PC端：
                    <div>
                        <input type="text" id="pcv-addr" readonly value="http://plive.appwuhan.com/{:date('Ymd',$streamList[0]['create_time'])}/whtv_{:md5($streamList[0]['group_id'])}.html" >
                        <span class="label" data-label="OK" data-clipboard-target="#pcv-addr"> 复制 <i class="fa fa-hand-pointer-o" aria-hidden="true"></i></span>
                    </div>
                </li>
                <li class="add-list">
                    移动端：
                    <div>
                        <input type="text" id="yun-addr" readonly value="http://plive.appwuhan.com/{:date('Ymd',$streamList[0]['create_time'])}/whtvm_{:md5($streamList[0]['group_id'])}.html" >
                        <span class="label" data-label="OK" data-clipboard-target="#yun-addr"> 复制 <i class="fa fa-hand-pointer-o" aria-hidden="true"></i></span>
                    </div>
                </li>
                <li class="add-list">
                    掌上武汉：
                    <div>
                        <input type="text" id="zswh-addr" readonly value="http://plive.appwuhan.com/{:date('Ymd',$streamList[0]['create_time'])}/zswh_{:md5($streamList[0]['group_id'])}.html" >
                        <span class="label" data-label="OK" data-clipboard-target="#zswh-addr"> 复制 <i class="fa fa-hand-pointer-o" aria-hidden="true"></i></span>
                    </div>
                </li>
                <li class="add-list">
                    黄鹤云：
                    <div>
                        <input type="text" id="whhtv-addr" readonly value="{:md5($streamList[0]['group_id'])}" >
                        <span class="label" data-label="OK" data-clipboard-target="#whhtv-addr"> 复制 <i class="fa fa-hand-pointer-o" aria-hidden="true"></i></span>
                    </div>
                </li>
            </ul>
            </ul>
        </div>
    </div>
</div>
<div id="mask" unselectable="on"></div>
<?php if($auth['is_manage'] == 1) { ?>
    <!-- 详情设置 -->
    <div class="modal fade" id="liveInfo" tabindex="-1" role="dialog" aria-labelledby="liveInfo" aria-hidden="true">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <form action="{:U('updateDetail')}" method="post" enctype="multipart/form-data" id="detailForm" class="form-horizontal" role="form">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                        <h4>设置直播详情</h4>
                    </div>
                    <div class="modal-body list">
                        <div class="form-group">
                            <label for="title" class="col-sm-2 control-label">直播标题：</label>
                            <div class="col-sm-10"><input type="text" class="form-control" id="title" name="title" value="{$streamList[0]['title']}" /></div>
                        </div>
                        <div class="form-group">
                            <label for="live_intro" class="col-sm-2 control-label"><span>直播简介：</span></label>
                            <div class="col-sm-10">
                                <!--<script type="text/plain" id="live_intro" name='live_intro'>{:html_entity_decode($streamList[0]['intro'])}</script>
                                <script type="text/javascript">
                                    UE.getEditor('live_intro',{
                                        autoClearinitialContent:false,
                                        wordCount:false,
                                        initialFrameHeight:250,
                                        textarea:'live_intro',
                                        initialFrameWidth:'100%',
                                        zIndex :999999999999
                                    })
                                </script>-->
                                <textarea name="live_intro" id="live_intro" class="form-control"  rows="18">{:strip_tags($streamList[0]['intro'])}</textarea>

                            </div>
                        </div>

                        <div class="form-group">
                            <label  for="start_time" class="col-sm-2 control-label"><span>开始时间：</span></label>
                            <div class="col-sm-3"> <input type="text" class="form-control form_datetime" id="start_time" name="start_time" value="<?php echo date('Y-m-d H:i', $streamList[0]['start_time']) ?>"  /></div>
                            <script type="text/javascript">
                                $("#start_time").datetimepicker({
                                    format: 'yyyy-mm-dd hh:ii',
                                    autoclose: true,
                                    todayBtn: true,
                                    pickerPosition: "bottom-left",
                                    language:"zh-CN",
                                    minView: 2,
                                    forceParse: 0,
                                    minView: 0,
                                    minuteStep: 5
                                });
                            </script>
                        </div>

                        <div class="form-group">
                            <label  class="col-sm-2 control-label"><span>缩略图：</span></label>
                            <div class="col-sm-10">
                                <div id="uploader-demo">
                                    <div id="fileList" class="uploader-list">
                                        <div id="WU_FILE_0" class="file-item thumbnail">
                                            <img src="{$streamList[0]['image_url']}?imageView2/2/w/229/h/130"  style="height: 130px;max-width: inherit;" alt="">
                                        </div>
                                    </div>
                                    <div id="filePicker">选择图片</div>
                                </div>

                            </div>
                            <input type="hidden" name="image_url" id="image_url" value="{$streamList[0]['image_url']}">
                        </div>

                        <input type="hidden" name="group_id" value="{$streamList[0]['group_id']}" />
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                        <button type="submit" id="loginBTN" class="btn btn-danger">保存</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
<?php } ?>
<style>
    #downBox .list,#bitBox .list{min-height: 200px;}
    #downBox .form-control,#bitBox .form-control{display: inline;width: auto;}
</style>

<!--视频m3u8列表-->
<div class="modal fade" id="downBox" tabindex="-1" role="dialog" aria-labelledby="m3u8list" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title">

                    开始时间： <input size="16" type="text" value="{:date('Y-m-d')}"  class="form-control form_datetime" id="sTime">
                    结束时间： <input size="16" type="text" value="{:date('Y-m-d')}"  class="form-control form_datetime" id="eTime">
                    <button type="button" class="btn btn-sm btn-info" id="mediaBTN"><i class="glyphicon glyphicon-search"></i> 搜索</button>
                    <script type="text/javascript">
                        $(".form_datetime").datetimepicker({
                            format: 'yyyy-mm-dd',
                            autoclose: true,
                            todayBtn: true,
                            pickerPosition: "bottom-left",
                            language:"zh-CN",
                            minView: 2,
                            forceParse: 0
                        });


                    </script>
                </h4>
            </div>
            <div class="modal-body list">
                
                <div id="liveId" data-id=""></div>
                <ul id="sList" data-idlist="">
                    <div class="text-center">
                        <div class="loading"><span class="gauge-loader">Loading&#8230;</span><p>Loading...</p></div>
                    </div>
                    <hr>
                    <div class="col-sm-10"> <input type="text" class="form-control" id="re_live" name="return_live" value="{$streamList[0]['return_live']}" /></div>
                </ul>
            </div>
        </div>
    </div>
</div>

<!--视频列表查询帧率和码率-->
<div class="modal fade" id="bitBox" tabindex="-1" role="dialog" aria-labelledby="m3u8list" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title">

                    开始时间： <input size="16" type="text" value="{:date('Y-m-d')}"  class="form-control form_datetime" id="sTime2">
                    结束时间： <input size="16" type="text" value="{:date('Y-m-d')}"  class="form-control form_datetime" id="eTime2">
                    <button type="button" class="btn btn-sm btn-info" id="mediaBTN2"><i class="glyphicon glyphicon-search"></i> 搜索</button>
                    <script type="text/javascript">
                        $(".form_datetime").datetimepicker({
                            format: 'yyyy-mm-dd',
                            autoclose: true,
                            todayBtn: true,
                            pickerPosition: "bottom-left",
                            language:"zh-CN",
                            minView: 2,
                            forceParse: 0
                        });


                    </script>
                </h4>
            </div>
            <div class="modal-body list">
                
                <div id="liveId2" data-id=""></div>
                <ul id="bList" data-idlist="">
                    <div id="txt">
                        <div class="text-center">
                            <div class="loading"><span class="gauge-loader">Loading&#8230;</span><p>Loading...</p></div>
                        </div>
                    </div>

                    <div id="va"></div>
                    <div id="bit"></div>
                </ul>
            </div>
        </div>
    </div>
</div>

<?php if($_SESSION['is_admin']) { ?>
    <!--权限设置记者列表-->
    <div class="modal fade" id="authBox" tabindex="-1" role="dialog" aria-labelledby="m3u8list" aria-hidden="true">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4 class="modal-title">
                        搜索记者： <input size="16" type="text" value=""  class="form-control form_datetime" id="reporter">
                        <button type="button" class="btn btn-sm btn-info" id="reporterBTN"><i class="glyphicon glyphicon-search"></i> 搜索</button>
                    </h4>
                </div>
                <div class="modal-body list">
                    <ul id="rList" data-idlist="">
                        <div class="text-center">
                            <div class="loading"><span class="gauge-loader">Loading&#8230;</span><p>Loading...</p></div>
                        </div>

                    </ul>
                </div>
            </div>
        </div>
    </div>

    <!-- 权限修改 -->
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">权限配置</h4>
                </div>
                <div class="modal-body">
                    <div class="whtv-select">
                        <div class="select-info">
                            <div class="wrap">
                                <?php foreach($reporterGroup as $val) { ?>
                                    <div class="select-item">
                                        <span class="text">{$val['realname']}</span>
                                        <span class="delete" value="{$val['uid']}"></span>
                                    </div>
                                <?php } ?>
                            </div>
                        </div>
                        <div class="select-list">
                            <select id="whtvSelect" multiple="multiple">
                                <?php foreach($reporterTotal as $val) { ?>
                                    <option value="{$val['uid']}">{$val['realname']}</option>
                                <?php } ?>
                            </select>
                        </div>
                    </div>
                </div>

            </div>
        </div>
    </div>
<?php } ?>

<!-- 查看浏览直播的详情 -->
<div class="modal fade" id="thumbModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <form action="http://upload.qiniu.com/" method="post"  id="liveForm" class="form-horizontal" role="form" enctype="multipart/form-data">
            <input name="token" type="hidden" value="{$liveToken}">
            <input name="x:liveId" type="hidden" id="thumbLiveId" value="0">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title">上传缩略图</h4>
                </div>
                <div class="modal-body list">
                    <div class="form-group">
                        <label  for="thumb" class="col-sm-2 control-label"><span>缩略图：</span></label>
                        <div class="col-sm-10"> <input type="file" class="form-control" id="thumb" name="file"  /></div>
                        <div class="error"></div>
                    </div>
                    <div class="form-group" id="imgThumb">

                    </div>
                    <!--<input type="hidden" name="liveid" value="0" />-->
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="submit" class="btn btn-danger" id="thumbBtn">保存</button>
                </div>
            </div>
        </form>
    </div>
</div>
<!-- 24小时拉流 -->
<div class="modal fade bs-example-modal-sm" tabindex="-1" id="h24rtmp" role="dialog" aria-labelledby="h24rtmp" aria-hidden="true">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
       <div id="rtmp" style="padding:15px"></div>
    </div>
  </div>
</div>

<!-- 24小时推流 -->
<div class="modal fade bs-example-modal-sm" tabindex="-1" id="h24PushRtmp" role="dialog" aria-labelledby="h24rtmp" aria-hidden="true">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
       <div id="PushRtmp1" style="padding:15px">
       	rtmp地址：<input type="text" class="form-control" value="">
       </div>
       <div id="PushRtmp2" style="padding:15px">
       	直播码：<textarea  rows="3" class="form-control"></textarea>
       </div>

       <div  style="padding:15px">
       	<p>
       		<strong>注：</strong>每次点击获取推流码都会重新生成直播码，每个直播码有效期24小时！
       	</p>
       </div>
    </div>
  </div>
</div>

<!-- 预览和打点 -->
<div class="modal fade" tabindex="-1" id="preview" role="dialog" aria-labelledby="preview" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">视频预览与裁剪</h4>
            </div>
            <div class="modal-body">
                <div id="return_player"  class="prism-player"></div>
                <div class="btns text-center" style="padding-top:15px;display: block">
                    <button class="btn btn-sm btn-warning" type="button" id="setVSTime">设置开始时间</button>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <button class="btn btn-sm btn-warning" type="button" id="setVETime">设置结束时间</button>
                </div>
            </div>
            <div class="modal-footer" style="text-align: center">
                <form class="form-inline" role="form">
                    <div class="form-group">
                        生成新的视频：
                    </div>
                    <div class="form-group">
                        <label  for="v_start_time" style="display: inline">开始时间</label>
                        <input type="text" class="form-control" name="v_start_time" id="v_start_time">
                    </div>
                    <div class="form-group">
                        <label  for="v_end_time" style="display: inline">结束时间</label>
                        <input class="form-control" type="text" name="v_end_time" id="v_end_time">
                    </div>
                    <button type="button" class="btn btn-sm btn-info" id="makeNewM3U8">确定生成</button>
                </form>
            </div>
        </div>
    </div>
</div>

<div id="model-hidden" style="display:none">
    <div class="select-item">
        <span class="text"></span>
        <span class="delete"></span>
    </div>
</div>

<iframe src="" name="downloadif" id="downloadif" frameborder="0" style="display: none" height="0" width="0"></iframe>
<script src="__PUBLIC__/live/js/aleart.js"></script>
<script src="__PUBLIC__/js/layer/layer.js"></script>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/js/layer/skin/layer.css">
<script>
<?php if($_SESSION['is_admin']) { ?>
    function formatTime(num){
        var d=new Date(num*1000);
        var h=d.getHours()-8;
        h=h>9?h:"0"+h;
        var m=d.getMinutes();
        m=m>9?m:"0"+m;
        var s=d.getSeconds();
        s=s>9?s:"0"+s;
        var str="";
        str+=h+":";
        str+=m+":";
        str+=s;
        return str;
    }
     var ws= new ReconnectingWebSocket("ws://socket.appwuhan.net:10088");
     var return_player;

     $("#sList").on("click",".previewStream",function(){

          $("#makeNewM3U8").data('stream',$(this).data('stream'));
         $("#makeNewM3U8").data('time',$(this).parents('li').find('.vtime').text());
         $("#makeNewM3U8").data('duration',$(this).parents('li').find('.vtime').data('duration'));

         return_player = new prismplayer({
             id: "return_player",
             source: 'http://whtv-out.oss-cn-hangzhou.aliyuncs.com/'+$(this).data('oss'),
             autoplay: false,
             isLive:false,
             width: "100%",
             height: "500px",
             showBarTime:3600*24*1000
         });
         return_player.on("play", function() {
             $("#makeNewM3U8").data('videolong',return_player.getDuration());
         });

         $("#preview").modal('show');
     });

     $('#preview').on('hidden.bs.modal', function (e) {
         $("#return_player").empty();
         $("#v_start_time,#v_end_time").val("");
         $("#makeNewM3U8").html('确定生成').prop('disabled', false);
     });

     $("#setVSTime").click(function(){

         if(formatTime(return_player.getCurrentTime())<$("#v_end_time").val() || $("#v_end_time").val()==""){
             $("#v_start_time").val(formatTime(return_player.getCurrentTime())).data("t",return_player.getCurrentTime());
         }else{
            alert("不能大于结束时间");
         }
     });

    $("#setVETime").click(function(){
        return_player.pause();

        if(formatTime(return_player.getCurrentTime())>$("#v_start_time").val() || $("#v_start_time").val()==""){
            $("#v_end_time").val(formatTime(return_player.getCurrentTime())).data("t",return_player.getCurrentTime());
        }else{
            alert("不能小于开始时间");
        }

    });

    $("#makeNewM3U8").on("click",function(){
        if(confirm("是否确定生成新的视频文件？")){
            var _this=this;
            if($("#v_end_time").val()!="" && $("#v_start_time").val()!="" && $("#v_end_time").val()>$("#v_start_time").val() && confirm('是否确定生成新的视频文件?')) {
                $(_this).html('生成中...').prop('disabled', true);
                var vTime = $(_this).data('time');
                vTime = vTime.split("—");

                var sTime = vTime[0];
                var tmp = sTime.split(" ");
                var st = new Date(sTime);
                sTime = Math.round(st.getTime() / 1000 + parseInt($("#v_start_time").data("t")));

                var eTime = tmp[0] + " " + vTime[1];
                var et = new Date(eTime);

                var videolong= Math.round(Math.abs(parseInt(et.getTime())-parseInt(st.getTime()))/1000);
             
                var videolong2= Math.round($(_this).data('duration'));

                eTime = Math.round(et.getTime() / 1000 - (videolong-parseInt($("#v_end_time").data("t"))))+(videolong-videolong2); 


                $.ajax({
                    url: '{:U("Oss/ajaxMakeM3U8")}',
                    data: {sTime: sTime, eTime: eTime, stream: $(_this).data('stream')},
                    //async:false,
                    success: function (data) {
                        if (data.code == 0) {
                            alert("成功生成新的视频文件！");
                            $("#preview").modal('hide');
                            $("#sList").load("{:U('Oss/ajaxMediaList')}?id="+$('#liveId').data('id')+"&sTime="+$("#sTime").val()+"&eTime="+$("#eTime").val());
                        }else{
                            alert(data.msg);
                            $(_this).html('确定生成').prop('disabled', false);
                        }
                    }
                })
            }
        }
    })


    //多选下拉列表
    $("#whtvSelect").multiseSelect({width:$(this).parent().width()+'px'});
    $(".multiselect-input").addClass('form-control').attr("placeholder","输入记者名字搜索");;
    $(".multiselect-img").hide().click();
    $(".select-list").append($(".multiselect-content"));
    //添加事件
    $(".multiselectCheckDiv").click(function(){

        var num = $(this).index();
        var txt = $(this).html();
        var value = $(this).attr("value");

        $.post('{:U("ajaxAddReporter")}?group_id={$Think.get.group_id}', {'uid':value}, function (data) {
            if(data['status'] == 1) {
                $(".select-info .wrap").append($("#model-hidden .select-item").clone(true));
                var item = $(".select-info .wrap .select-item").last();
                item.find('.text').html(txt);
                item.find('.delete').attr("value",value);
            } else {
                $.alert(data.msg);
            }
        })
    });
    //删除事件
    $(".delete").click(function(){
        var value = $(this).attr('value');
        var _this = this;

        $.post('{:U("ajaxDelReporter")}?group_id={$Think.get.group_id}', {'uid':value}, function (data) {
            if(data['status'] == 1) {
                $(_this).parent().remove();
            } else {
                $.alert(data.msg);
            }
        })
    });
    <?php } ?>
    $(window).load(function(){
        var scrollTop = localStorage.getItem("scrollTop")==null?0:localStorage.getItem("scrollTop");
        $(".sidebar-list").parent().scrollTop(scrollTop);
        $(".sidebar-list").click(function(){
            localStorage.setItem("scrollTop",$(this).parent().scrollTop());
        });
    });

    $("#setAuthBtn").click(function(){
        $('#myModal').modal('show')
    });


    $('#authBox') .on('hidden.bs.modal', function () {
        $("#sList").html('<div class="text-center"><div class="loading"><span class="gauge-loader">Loading&#8230;</span><p>Loading...</p></div></div>');
    })




    $(".download").click(function(){
        $('#downBox').modal('show')
        $("#sList").load("{:U('Oss/ajaxMediaList')}?id="+$(this).data('id'),function(d){
            $(d).find('img').each(function(){
                var idList=$("#downBox .list ul").data('idlist');
                idList=idList.split(',');
                if($.inArray($(this).data('streamid')+"", idList)==-1){
                    getProgress($(this).parent(),$(this).data('streamid'));
                }
            })
        })
        $('#liveId').data('id',$(this).data('id'));
    })

    $('#downBox') .on('hidden.bs.modal', function () {
        $("#sList").html('<div class="text-center"><div class="loading"><span class="gauge-loader">Loading&#8230;</span><p>Loading...</p></div></div>');
        //$('#liveId').data('id','');
    })

    $("#mediaBTN").click(function(){
        $("#sList").load("{:U('Oss/ajaxMediaList')}?id="+$('#liveId').data('id')+"&sTime="+$("#sTime").val()+"&eTime="+$("#eTime").val(),function(d){
            $(d).find('img').each(function(){
                var idList=$("#sList").data('idlist');
                idList=idList.split(',');
                if($.inArray($(this).data('streamid')+"", idList)==-1){
                    getProgress($(this).parent(),$(this).data('streamid'));
                }
            })
        })
    })

    $("#sList").on("click",".getURL",function(){
        var obj=this;
        $.ajax({
            dataType:"json",
            url:"{:U('Oss/transMTS')}?file="+$(obj).data('stream')+"&liveid="+$('#liveId').data("id"),
            success:function(d){
                switch(d.status){
                    case 0:
                        $.alert(d.msg+"，请稍后重试！");
                        break;
                    default:
                        var parent=$(obj).parent();
                        var idList=$("#sList").data('idlist');
                        idList=idList.split(',');
                        if($.inArray(d.msg.stream_id, idList)==-1){
                            idList[idList.length]=d.msg.stream_id;
                        }
                        idList=idList.join(',');
                        idList=idList.replace(/^,/,"");
                        $("#sList").data('idlist',idList);
                        $(obj).parent().html('<img src="__PUBLIC__/live/img/mtsloading.gif"   /> 转码中...');
                        getProgress(parent,d.msg.stream_id);
                }
            }
        })
    })

    $(".text-info").each(function(){
        $(this).load("{:U('showBTNs')}?id="+$(this).data('id'))
    })

    <?php if($auth['is_manage'] == 1) { ?>
    var val;
    $(".pos_name").dblclick(function(e){
        e.preventDefault();
        val=$(this).text();
        $(this).html("<input type='text' class='i_pos form-control' id='"+$(this).data("id")+"' />");
        $(this).find("input").focus().val(val);
    })


    $(".pos_name").on("blur",".i_pos",function(){
        var obj=this;
        if($(obj).val()!==val){
            if(confirm("是否确定修改此机位信息？")){
                $.get("{:U('ajaxEditPosName')}?id="+$(obj).attr("id")+"&posName="+$(obj).val(),function(data){
                    if(data==1){
                        $(obj).parent().html($(obj).val());
                    }else{
                        $(obj).parent().html(val);
                    }
                })
            }else{
                $(obj).parent().html(val);
            }
        }else{
            $(obj).parent().html(val);
        }
    })



    $('#pushStream').on('click', function (e) {
        e.preventDefault();
        var item = $(this);
        if(item.get(0).checked) {
            $.confirm("确定开启所有的直播通道吗？",function(){
                $.get("{:U('ajaxGroupStreamOn')}?groupid="+item.data('groupid'),function(data){
                    if(data.status==0){
                        $(".text-info").each(function(){
                            $(this).load("{:U('showBTNs')}?id="+$(this).data('id'))
                        })
                        item.prop("checked",true);
                    }else{
                        $.alert(data.msg);
                    }
                })},function(){})
        } else {
            $.confirm("确定关闭所有的直播通道吗？",function(){
                $.get("{:U('ajaxGroupStreamOff')}?groupid="+item.data('groupid'),function(data){
                    if(data.status==0){
                        $(".text-info").each(function(){
                            $(this).load("{:U('showBTNs')}?id="+$(this).data('id'))
                        })
                        item.prop("checked",false);

                    }else{
                        $.alert(data.msg);
                    }
                })
                // var data={action:'closeAllStream',group:'{$Think.get.group_id}'};
                // data=JSON.stringify(data)
                // ws.send(data);
            },function(){})
        }




    });

    $("#liveStatus").click(function(e){
        e.preventDefault();
        if($(this).is(":checked")==false){
            isLsEnd = 1;
            var item = $(this);
            $.confirm("确定结束所有直播吗？",function(){
                $.get("{:U('ajaxLiveStatusOff')}?groupid="+item.data('groupid'),function(data){
                    if(data.status==0){
                        location.reload();
                    }else{
                        $.alert(data.msg);
                    }
                })
                // var data={action:'closeAllStream',group:'{$Think.get.group_id}'};
                // data=JSON.stringify(data)
                // ws.send(data);
            },function(){
                // 取消func
            });
        }else{
            var item = $(this);
            $.confirm("确定将所有直播都开启吗？",function(){
                $.get("{:U('ajaxLiveStatusOn')}?groupid="+item.data('groupid'),function(data){
                    if(data.status==0){
                       location.reload();

                    }else{
                        $.alert(data.msg);
                    }
                })
                // var data={action:'closeAllStream',group:'{$Think.get.group_id}'};
                // data=JSON.stringify(data)
                // ws.send(data);
            },function(){
                // 取消func
            });
        }
    });



    $('#sortBtn').on('click', function () {
        var data = [];
        $('.livePos .posSort').each(function (i) {
            data[i] = [$(this).data('id'), $(this).val()];
        });

        $.post('{:U("ajaxUpdateSort")}?group_id={$streamList[0]["group_id"]}', {'data':data}, function (data) {
            if(data == 1) {
                $.alertRecall('排序更新成功',function(){
                    window.location.reload();
                });
            }else{
                $.alertRecall('服务器繁忙，请稍后重试！');
            }
        });
    });

    <?php } ?>


    $("#addr-model .label").click(function(){
        var item = $(this);
        $(this).parent().addClass("copying");
        setTimeout(function(){
            item.parent().removeClass("copying");
        },500);
    });

    var clipboard = new Clipboard('#addr-model .label');

    $(".imgClass").click(function(e){
        e.stopPropagation();
        $("#addr-model").show().addClass("show");
    });

    $(".close-cp a").click(function(){
        $("#addr-model").removeClass("show").hide();
    })

    function getProgress(obj,stream_id){
        var t;
        $.ajax({
            type:"json",
            url:"{:U('Oss/ajaxGetProgress')}?stream_id="+stream_id,
            success:function(data){
                if(data.status==1){
                    var percent=data.msg;
                    obj.html('<img src="__PUBLIC__/live/img/mtsloading.gif" />  转码中...')
                    if(percent==100){
                        clearTimeout(t);
                        obj.html('<a class="btn btn-xs btn-danger downloadMts" target="_blank"  href="http://download.appwuhan.net/Live/download.html?id='+stream_id+'">下载</a>')
                    }
                }
            }
        });
        t=setTimeout(function(){getProgress(obj,stream_id);},3000);
    }

    $('#pushBtn').click(function () {
        var _this = this;
        var status = $(this).data('status');
        $.post('{:U("setLivePush")}?group_id={$_GET["group_id"]}', {'status': status}, function (data) {
            if(data['status'] != 2) {
                if(data.status == 1) {
                    $(_this).html('撤回');
                    $(_this).data('status', 0);
                } else {
                    $(_this).html('签发');
                    $(_this).data('status', 1);
                }
                $.alert(data.msg);
            } else {
                $.alert(data.msg);
            }
        })
    });

    $('#topBtn').click(function () {
        var _this = this;
        var status = $(this).data('status');
        $.post('{:U("setLiveTop")}?group_id={$_GET["group_id"]}', {'status': status}, function (data) {
            if(data != 0) {
                if(data.status == 1) {
                    $(_this).html('关闭置顶');
                    $(_this).data('status', 0);
                } else {
                    $(_this).html('点击置顶');
                    $(_this).data('status', 1);
                }
                $.alert(data.msg);
            } else {
                $.alert('置顶失败');
            }
        })
    });

    $('.thumb').click(function () {
        $('#thumbModal').modal('show');
        $('#thumbModal input[name="liveid"],#thumbLiveId').val($(this).data('id'));
        $.get('{:U("getLiveThumb")}?liveid=' + $(this).data('id'), function (data) {
            if(data) {
                $('#imgThumb').html('<img src="' + data +'" height="130" />');
            } else {
                $('#imgThumb').html('');
            }
        })

    });

    $('#thumbBtn').click(function () {
        if($('#thumb').val() == '') {
            $('#thumbModal .error').html('还未选择文件');
            return false;
        } else {
            $('#thumbModal .error').html('');
        }
    });

    $("#downBox").on('click','.returnLive',function () {
        var _this = this;
        var id = $(_this).data('id');
        var url = $(_this).data('url');
        $.post('{:U("Oss/ajaxSetReturnLive")}', {id:id,url:url}, function (data) {
            if(data != 0) {
                $("#sList").load("{:U('Oss/ajaxMediaList')}?id="+$(_this).data('id'),function(d){
                    $(d).find('img').each(function(){
                        var idList=$("#downBox .list ul").data('idlist');
                        idList=idList.split(',');
                        if($.inArray($(this).data('streamid')+"", idList)==-1){
                            getProgress($(this).parent(),$(this).data('streamid'));
                        }
                    })
                })
                $('#liveId').data('id',$(_this).data('id'));

            } else {
                $.alert('设置失败，请重试');
            }
        }); 
    });

    $("#themeBtn").click(function(){
        var _this = this;
        var themeid = $(this).data('themeid');
        $.get('{:U("ajaxSetTheme")}?liveid={$Think.get.group_id}&themeid='+themeid,function(data){
            if(data != 0) {
                if(data.status == 1) {
                    $(_this).html('撤回直播王列表');
                    $(_this).data('themeid', 0);
                } else {
                    $(_this).html('签发直播王列表');
                    $(_this).data('themeid', 1);
                }
                $.alert(data.msg);
            } else {
                $.alert('设置失败，请重试');
            }
        })
    })

    $('.bitRate').on('click', function () {
        $('#bitBox').modal('show');

        $("#bList #txt").html('<div class="alert alert-info" role="alert">请选择时间范围查询视频</div>');

        $('#liveId2').data('id',$(this).data('id'));       
    })

    $("#mediaBTN2").click(function(){
        $('#bList #txt').html('<div class="loading"><span class="gauge-loader">Loading&#8230;</span><p>Loading...</p></div>');
       $.getJSON("{:U('getLiveStreamsFrameRateAndBitRate')}?id="+$('#liveId2').data('id')+"&sTime="+$("#sTime2").val()+"&eTime="+$("#eTime2").val(),function(d){
       	if(d.code!=0){
            $('#bList #txt').html("");
            $('#va,#bit').css("height","250px")
       		Highcharts.chart('va', {
                chart: {zoomType: 'x'},
                title: {text: ''},
                subtitle: {
                    text: ''
                },
                xAxis: {
                    type: 'datetime',
                    dateTimeLabelFormats: {
                        minute: '%H:%M',
                        hour: '%H:%M',
                        day: '%m-%d',
                        week: '%m-%d',
                        month: '%Y-%m',
                        year: '%Y'
                    }
                },
                tooltip: {
                    dateTimeLabelFormats: {
                        minute: '%Y-%m-%d %H:%M',
                        hour: '%Y-%m-%d %H:%M',
                        day: '%Y-%m-%d %H:%M',
                        week: '%Y-%m-%d %H:%M',
                        month: '%Y-%m-%d %H:%M',
                        year: '%Y-%m-%d %H:%M'
                    }
                },
                yAxis: {
                    title: {
                        text: ''
                    }
                },
                legend: {
                    enabled: false
                },
                plotOptions: {
                    area: {
                        fillColor: {
                            stops: [
                                [1, Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0).get('rgba')]
                            ]
                        },
                        marker: {radius: 2},
                        lineWidth: 1,
                        states: {
                            hover: {
                                lineWidth: 1
                            }
                        },
                        threshold: null
                    }
                },

                series: [{
                    type: 'area',
                    name: '视频帧率',
                    data: d.VideoFrameRate
                },{
                    type: 'area',
                    name: '音频帧率',
                    data: d.AudioFrameRate
                }]
            });

            Highcharts.chart('bit', {
                chart: {zoomType: 'x'},
                title: {text: ''},
                subtitle: {
                    text: ''
                },
                xAxis: {
                    type: 'datetime',
                    dateTimeLabelFormats: {
                        minute: '%H:%M',
                        hour: '%H:%M',
                        day: '%m-%d',
                        week: '%m-%d',
                        month: '%Y-%m',
                        year: '%Y'
                    }
                },
                tooltip: {
                    dateTimeLabelFormats: {
                        minute: '%Y-%m-%d %H:%M',
                        hour: '%Y-%m-%d %H:%M',
                        day: '%Y-%m-%d %H:%M',
                        week: '%Y-%m-%d %H:%M',
                        month: '%Y-%m-%d %H:%M',
                        year: '%Y-%m-%d %H:%M'
                    }
                },
                yAxis: {
                    title: {
                        text: ''
                    }
                },
                legend: {
                    enabled: false
                },
                plotOptions: {
                    area: {
                        fillColor: {
                            stops: [
                                [1, Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0).get('rgba')]
                            ]
                        },
                        marker: {radius: 2},
                        lineWidth: 1,
                        states: {
                            hover: {
                                lineWidth: 1
                            }
                        },
                        threshold: null
                    }
                },

                series: [{
                    type: 'area',
                    name: '码率',
                    data: d.BitRate
                }]
            });
         }
       })
    })
/*评论面板开关*/
    $('#comment').on('click', function () {
        if($(this).hasClass('btn-info')){
            $(this).removeClass('btn-info').addClass('btn-default');
            $(".liveView").slideDown().siblings('.tab').slideUp();

        }else{
            $(this).removeClass('btn-default').addClass('btn-info').siblings().removeClass('btn-info').addClass('btn-default');;
            $(".comment").slideDown().siblings('.tab').slideUp();
        }
    });

    $('.sendmsg').on('click', function () {
        if(!$(this).hasClass('sending')){
            var name=$(this).parents('.push-to').find('.sendname').val();
            var group=$(this).parents('.push-to').find('.sendgroup').val();
            var content=$.trim($(this).parents('.push-to').find('.pushmsg').val());

            if(!content) {
                alert('消息不能为空');
                return false;
            }
            $(this).addClass('sending');



            var data={action:'backend_write_data',group:group, name:name, content:content};
            data=JSON.stringify(data)
            ws.send(data);
        // alert('发送成功');
        }
    });

    ws.onmessage = function (evt) {
        var received_msg = $.parseJSON(evt.data);

        if(received_msg.type=='ping'){
            var data={type:'pong'};
            data=JSON.stringify(data)
            ws.send(data);
            return ;
        }

        if(received_msg.act == 'backend') {
            if(received_msg.status == 1) {
                $('.sendmsg').removeClass('sending');
                $('.pushmsg').val("");
                alert('发送成功');
            } else {
                alert('发送失败');
            }       
        }
    }

    function editReturn(id,obj){
        if(confirm("是否确定修改此机位的回看？")){
            $(obj).attr("disabled","disabled").html('修改中...');
            $.ajax({
                type:'post',
                url:'{:U('ajaxEditReturnLive')}',
                data:{id:id,returnLive:$(obj).prev('input').val()},
                async:false,
                success:function(data){
                    if(data<0){
                        alert('修改失败!');
                    }else{
                        $(obj).removeAttr('disabled').html('确定修改');
                        if(data>0){
                            alert('修改成功！');
                        }
                    }
                }
            });
        }

    }
    $(".rtmp").click(function(){
    	$.get("{:U('ajaxGetLongRtmp')}?id="+$(this).data('id'),function(data){
    		if(data!=-1){
    			$("#rtmp").html(data);
    			$("#h24rtmp").modal('show');
    		}
    	})
    })

    $(".m3u8").click(function(){
        $.get("{:U('ajaxGetLongM3u8')}?id="+$(this).data('id'),function(data){
            if(data!=-1){
                $("#rtmp").html(data);
                $("#h24rtmp").modal('show');
            }
        })
    })


    $(".pushrtmp").click(function(){
    	$.get("{:U('ajaxGetLongPushRtmp')}?id="+$(this).data('id'),function(data){
    		if(data!=-1){

    			var arr=data.split('/');
    			var s1=arr[0]+"//"+arr[2]+"/"+arr[3];
    			var s2=arr[4];


    			$("#PushRtmp1 input").val(s1);
    			$("#PushRtmp2 textarea").html(s2);
    			$("#h24PushRtmp").modal('show');
    		}
    	})
    })





    $("#searchInput").on('keyup',function(){
        $(".sidebar-list").parent().html($(".sidebar-list").parent().html().replace(/<\/?span.*?>/g,''));

        if($.trim($(this).val()) != ''){
            var reg = new RegExp('('+$.trim($(this).val())+')','g');
            $(".sidebar-list a").each(function(index,item){
                //$(item).find('span')

                var tmp =item.innerHTML;

                if(reg.test(tmp)){
                    var i = tmp.replace(reg,'<span class="selected">'+RegExp.$1+'</span>');
                    item.innerHTML= i;
                    $(this).parent().show();
                }else{
                    $(this).parent().hide();
                }
            });
        }else{

            $(".sidebar-list").show();
        }
    });
/*机位管理界面切换*/
    $("#managePos").click(function(){
        if($(this).hasClass('btn-info')){
            $(this).removeClass('btn-info').addClass('btn-default');
            $(".liveView").slideDown().siblings('.tab').slideUp();

        }else{
            $(this).removeClass('btn-default').addClass('btn-info').siblings().removeClass('btn-info').addClass('btn-default');
            $(".livePos").slideDown().siblings('.tab').slideUp();
        }
    })
/*列表图上传*/
var uploader;
$("#liveInfo").on('hide.bs.modal',function(){

    $("#fileList .thumbnail").html('<img src="{$streamList[0]['image_url']}"  style="height: 130px;" alt="">');
    uploader.reset();
    uploader.destroy();
});


$("#liveInfo").on('shown.bs.modal',function(){
        uploader = WebUploader.create({
            auto: false,
            swf: '__PUBLIC__/webuploader/Uploader.swf',
            server: 'http://upload.qiniu.com',
            pick: '#filePicker',
            accept: {
                title: 'Images',
                extensions: 'gif,jpg,jpeg,bmp,png',
                mimeTypes: 'image/*'
            },
            thumb:{
                crop: false,
            },
            compress:false,
            formData:{
                token:"{$uploadToken}",
            },
            fileNumLimit:1
        });

        uploader.on('beforeFileQueued',function(){
            $("#loginBTN").attr('type','button');
              $("#fileList").empty();
            uploader.reset();
        })

        uploader.on( 'fileQueued', function( file ) {
            var $li = $(
                            '<div id="' + file.id + '" class="file-item thumbnail">' +
                            '<img>' +
                            '</div>'
                    ),
                    $img = $li.find('img');
            $("#fileList").append( $li );
            uploader.makeThumb( file, function( error, src ) {
                if ( error ) {
                    $img.replaceWith('<span>不能预览</span>');
                    return;
                }
                $img.attr( 'src', src );
            }, 1, 130 );
        });

        uploader.on( 'uploadProgress', function( file, percentage ) {
            var $li = $( '#'+file.id ),
                    $percent = $li.find('.progress span');
            if ( !$percent.length ) {
                $percent = $('<p class="progress"><span></span></p>')
                        .appendTo( $li )
                        .find('span');
            }

            $percent.css( 'width', percentage * 100 + '%' );
        });


        uploader.on( 'uploadSuccess', function( file ,response ) {
            $( '#'+file.id ).addClass('upload-state-done');
            $("#image_url").val('http://image.jianweitv.com/'+response.key);
            $("#loginBTN").attr('type','submit');
            $("#detailForm").submit();
        });

        uploader.on( 'uploadError', function( file ) {
            var $li = $( '#'+file.id ),
                    $error = $li.find('div.error');

            if ( !$error.length ) {
                $error = $('<div class="error"></div>').appendTo( $li );
            }

            $error.text('上传失败');
        });

        uploader.on( 'uploadComplete', function( file ) {
            $( '#'+file.id ).find('.progress').remove();
        });
});

$("#loginBTN").click(function(){
    if(!$(this).is(":submit")){
        uploader.upload();
    }
})

$(".statusbtnlist .btn:not(.testing)").click(function(){
    var _this=this;
    //console.log($(_this).parents('.btnlist').data('groupid'))
    $.ajax({
        url:"{:U('ajaxSetLiveStatus')}",
        async:false,
        data:{group_id:$(_this).parents('.statusbtnlist').data('groupid'),status:$(_this).data('status')},
        success:function(data){
            if(data.status===0){
                location.reload();

            }else{
                $.alert(data.msg);
            }
        }
    })
});

$('.text-info').on('click', '.btn', function (e) {

    console.log(1111);
    e.preventDefault();
    var item = $(this);

    switch(item.data('status')){
        case 3:
            $.confirm("确定结束<span style='color:red;font-weight: bold;'>"+item.parents("li").find(".zbRen").text()+"</span>的直播吗？<p style='color:red;font-size:12px'>（结束后不能重新开启）</p>",function(){
                $.get("{:U('ajaxLiveOff')}?liveId="+item.data('id')+"&stream="+item.data('stream'),function(data){
                    if(data.status==0){
                        item.parents('.text-info').load("{:U('showBTNs')}?id="+item.data('id'));
                        if(data.groupId==3){
                            $('#liveStatus').prop('checked',false);
                            $('#liveStatus').prop("disabled",true);
                            $('#liveStatus').next().addClass("disabled");

                            $('#pushStream').parents(".col-50").remove();
                        }
                    }else{
                        $.alert(data.msg);
                    }
                })

                // var data={action:'closeStream',group:'{$Think.get.group_id}',id:item.data('id')};
                // data=JSON.stringify(data)
                // ws.send(data);

            },function(){})
            break;
        case 1:
            $.confirm("确定开启<span style='color:red;font-weight: bold;'>"+item.parents("li").find(".zbRen").text()+"</span>的直播通道吗？",function(){
                $.get("{:U('ajaxStreamOn')}?liveId="+item.data('id')+"&stream="+item.data('stream'),function(data){

                    if(data.status==0){
                        item.parents('.text-info').load("{:U('showBTNs')}?id="+item.data('id'));
                        if(data.groupId==1){
                            $('#pushStream').prop('checked',true);
                        }
                    }else{
                        $.alert(data.msg);
                    }
                })},function(){})
            break;
        case 0:
            $.confirm("确定关闭<span style='color:red;font-weight: bold;'>"+item.parents("li").find(".zbRen").text()+"</span>的直播通道吗？",function(){
                $.get("{:U('ajaxStreamOff')}?liveId="+item.data('id')+"&stream="+item.data('stream'),function(data){
                    if(data.status==0){
                        item.parents('.text-info').load("{:U('showBTNs')}?id="+item.data('id'));
                        if(data.groupId==0){
                            $('#pushStream').prop('checked',false);
                        }
                    }else{
                        $.alert(data.msg);
                    }
                });

                var data={action:'closeStream',group:'{$Think.get.group_id}',id:item.data('id')};
                data=JSON.stringify(data)
                ws.send(data);


            },function(){})
            break;
        case 4:
            $.confirm("确定<span style='color:red;font-weight: bold;'>"+item.parents("li").find(".zbRen").text()+"</span>的直播进行测试吗？<p style='color:red;font-size:12px'>（结束后不能重新开启）</p>",function(){
                $.get("{:U('ajaxSetLiveTesting')}?liveId="+item.data('id')+"&stream="+item.data('stream'),function(data){
                    if(data.status==0){
                        item.parents('.text-info').load("{:U('showBTNs')}?id="+item.data('id'));
                        if(data.groupId==3){
                            $('#liveStatus').prop('checked',false);
                            $('#liveStatus').prop("disabled",true);
                            $('#liveStatus').next().addClass("disabled");

                            $('#pushStream').parents(".col-50").remove();
                        }
                    }else{
                        $.alert(data.msg);
                    }
                })

                // var data={action:'closeStream',group:'{$Think.get.group_id}',id:item.data('id')};
                // data=JSON.stringify(data)
                // ws.send(data);

            },function(){})
            break;
    }
})
/*评论面板开关*/
    $("[name='is_verify']").bootstrapSwitch();
    $("[name='is_verify']").on('switchChange.bootstrapSwitch', function(event, state) {
        event.preventDefault();

        var _this = this;
        status=state===false?0:1;
        $.post('{:U("setLiveVerify")}?group_id={$_GET["group_id"]}', {'status': status}, function (data) {
            if(data['status'] != 2) {
                if(data.status == 1) {
                    $(_this).bootstrapSwitch('setState', true,true);
                } else {
                    $(_this).bootstrapSwitch('setState', false, false);
                }
            } else {
                $(_this).bootstrapSwitch('setState',state,state);
                $.alert(data.msg);
            }
        })
    });
</script>
</body>
</html>



